<template>
  <!-- 取消随访详情 -->
  <section>
    <div style="border-bottom:1px solid #eee;padding-bottom:10px;">
      <el-page-header @back="goBack" content="随访任务详情"></el-page-header>
    </div>
    <br />
    <div style="display: flex;">
      <!-- <div style="flex-shrink: 0;margin-right:15px;">
        <patientBasicInfo v-if="visitDetail.patientId" :patientId="visitDetail.patientId"></patientBasicInfo>
      </div>-->
      <div style=" flex-grow: 1;">
        <h3 style="margin:0;">患者信息</h3>
        <hr />
        <table style="border:none;width:100%;">
          <tr style="height:35px;">
            <td>患者：{{patientDetail.name}}</td>
            <td>证件号：{{patientDetail.idCard}}</td>
            <td colspan="2">性别：{{patientDetail.sex | toSex}}</td>
          </tr>
          <tr style="height:35px;">
            <td>
              年龄：
              <label
                v-if="patientDetail.age<18"
              >{{patientDetail.age}}岁{{patientDetail.sdfMonth}}个月{{patientDetail.sdfDay}}天</label>
              <label v-else>{{patientDetail.age}}岁</label>
            </td>
            <td>出生日期：{{patientDetail.birthday}}</td>
            <td>手机号：{{patientDetail.mobile}}</td>
            <!-- <td>民族：{{patientDetail.scheduleVisitTime}}</td> -->
          </tr>
          <tr style="height:35px;">
            <td
              colspan="4"
            >住址：{{patientDetail.province}}{{patientDetail.city}}{{patientDetail.district}}{{patientDetail.address}}</td>
          </tr>
          <tr style="height:35px;">
            <td>计划随访日期：{{visitDetail.scheduleVisitTime}}</td>
            <td>科室：{{visitDetail.deptName}}</td>
            <td>主管医生：{{visitDetail.doctorName}}</td>
            <td>计划随访人员：{{visitDetail.scheduleVisitUserName}}</td>
          </tr>
          <tr style="height:35px;">
            <td colspan="4">重要信息备注：{{visitDetail.remark}}</td>
          </tr>
          <tr style="height:35px;">
            <td colspan="4">随访类型：{{visitDetail.visitType}}</td>
          </tr>
          <tr style="height:35px;">
            <td colspan="4">随访项目：{{visitDetail.visitContent}}</td>
          </tr>
          <tr style="height:35px;">
            <td colspan="4">取消原因：{{visitDetail.cancelReason}}</td>
          </tr>
          <tr style="height:35px;">
            <td colspan="4">取消人员：{{visitDetail.cancelUserName}}</td>
          </tr>
        </table>
      </div>
    </div>
  </section>
</template>
<script>
import enumArr from "./_enum/enum";
export default {
  data() {
    return {
      btnLoading: false,
      qxBtns: {},
      //随访任务详情
      visitDetail: {
        //创建人
        createName: "",
        //创建时间
        createTime: "",
        //科室名称
        deptName: "",
        //医生
        doctorName: "",
        recordId: "",
        //随访时间
        scheduleVisitTime: "",
        //随访项目
        visitProject: "",
        //随访类型
        visitType: "",
        scheduleVisitUserName: "",
        cancelUserName: "",
        remark: "",
        cancelReason: "",
        visitContent: "",
      },
      form: {
        recordId: "",
      },
      patientDetail: {},
    };
  },
  created() {
    this.form.recordId = this.jieMi(this.$route.query.id);
  },
  async mounted() {
    this.getVisitDetail();
  },
  methods: {
    //获取随访详情
    async getVisitDetail() {
      const { recordId } = this.form;
      if (recordId)
        await this.$api.getVisitRecordDetail({ id: recordId }).then((res) => {
          if (res.executed) {
            let d = res.dataBody;
            const {
              createName,
              createTime,
              deptName,
              recordId,
              doctorName,
              scheduleVisitTime,
              visitProject,
              visitType,
              result,
              visitWay,
              visitUserId,
              visitTime,
              cancelUserName,
              cancelReason,
              scheduleVisitUserName,
              id,
              patientId,
              remark,
              visitContent,
            } = d;
            this.visitDetail = {
              //创建人
              createName: createName,
              //创建时间
              createTime: createTime,
              //科室名称
              deptName: deptName,
              //医生
              doctorName: doctorName,
              recordId: recordId,
              //随访时间
              scheduleVisitTime: scheduleVisitTime,
              scheduleVisitUserName,
              cancelUserName,
              cancelReason,
              //随访项目
              visitProject: visitProject,
              //随访类型
              visitType: visitType,
              remark,
              patientId,
              visitContent,
            };
            this.form = {
              recordId,
              id,
            };
          }
        });
      await this.$api
        .getThePatientLibraryById({ patientId: this.visitDetail.patientId })
        .then((res) => {
          if (res.executed) {
            this.patientDetail = {
              ...this.patientDetail,
              ...res.thePatientLibraryDetail,
            };
          }
        });
    },
    goBack() {
      const th = this;
      th.$router.push({
        path: "visit",
      });
    },
  },
};
</script>